export default {
  namespaced: true,
  state: () => ({
    historys: [],
  }),

  mutations: {
    // 新增
    addHistory(state, newHistory) {
      const isFindIndedx = state.historys.findIndex(item => item === newHistory)
      if (isFindIndedx !== -1) {
        state.historys.splice(isFindIndedx, 1)
      }
      state.historys.unshift(newHistory)
    },

    // 单个删除
    delHistory(state, index) {
      state.historys.splice(index, 1)
    },

    // 全部删除
    deleteAllHistory(state) {
      state.historys = []
    }
  },
};
